<template>
    <div class="cbox">
        <h4>子组件A</h4>
        <p>msg:{{ msg }}</p>
        <input type="button" value="setMsg" @click=" updateMsg( Math.random() ) ">
        <br>
        <input type="button" value="触发loadMsg" @click="initMsg()">

    </div>
</template>

<script setup>
import { computed } from "@vue/reactivity";
import { useStore } from "vuex";

const $store = useStore();

let msg = computed(()=>{
    return $store.state.msg
})
const updateMsg = function(nv){
    $store.commit("setMsg",nv)
}
const initMsg = function(){
    $store.dispatch("loadMsg",{ query:1 })
}

</script>

<style lang="sass" scoped>

</style>